<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* 
*/
class CourseReport extends MY_Controller
{
	
	public function __construct()
	{
		parent::__construct();
		
		$this->load->model('Statis/CourseReportModel','courep');
	}


	public function index()
	{
		$data = $this->courep->course_count();

		//获取教练
		$query = $this->db->query("SELECT id, nickname FROM nmp_coach");
		$data['coach_list'] = $query->result_array();

		//获取场馆
		$query = $this->db->query("SELECT id, name FROM nmp_shop");
		$data['venue_list'] = $query->result_array();

		$this->load->view('course_report', $data);
	}


	//
	public function course_appoint()
	{

		$date_num = $this->input->get('date_num');

		$res = $this->courep->course_appoint_data($date_num);

		if ($res) 
		{
			$data = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['list'] = '';
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}


	//
	public function user_appoint()
	{
		$venue_id = $this->input->get('venue_id');
		$coach_id = $this->input->get('coach_id');
		$dates = $this->input->get('dates');
		$keyword = $this->input->get('keyword');
		$page = $this->input->get('page');
		$page = $page ? $page : 1;

		$res = $this->courep->get_appoint($venue_id,$coach_id,$dates,$keyword,$page);

		if ($res) 
		{
			$data = $res;
			$data['status'] = 200;
			$data['message'] = '获取成功！';
		}
		else
		{
			$data['list'] = '';
			$data['status'] = 400;
			$data['message'] = '数据获取失败！';
		}

		echo json_encode($data);exit();

	}



}



?>